﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;

namespace GWEB.WebFrame.Models
{
    public class User
    {
        public PageInfo Init()
        {
            PageInfo pg = new PageInfo();
            pg.Type = "User";
            pg.Title = "用户管理";
            pg.ConditionColumn = 2;
            pg.AddText = "用户增加";
            pg.EditText = "用户修改";
            pg.LocateText = "用户信息查询";
            pg.SMenuId = "CS01";
            pg.FileUrl = "../Sys/User";
            pg.Condition = "";
            pg.TableName = "tb_sys_users";
            pg.KeyFieldName = "iuserid";
            pg.PopEditHeight = 500;
            pg.PopEditWidth = 700;

            HttpSessionState session = System.Web.HttpContext.Current.Session;
            pg.dict = BasePage.getDict(session);
            
            pg.Sop = BasePage.Grant(session, pg.SMenuId);
            pg.Sql = @"select * from ( 
                        select t1.*,t2.dname as enabled
                        from tb_sys_users t1 
                        left join tb_sys_dictionary t2 on t1.bstopflag=t2.did and t2.typeid='A04'                 
                    ) tb_sys_users where 1=1 ";
            ColumnInfo cl;
            cl = new ColumnInfo(); cl.FieldName = "susername"; cl.HeadText = "用户名"; cl.IsCondition = true; cl.IsCheck = true; cl.Length = 20; cl.IsNull = false; cl.IsUnique = true; cl.ErrMessage = "用户名:必填且长度不能超过20或重复"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "sshowname"; cl.HeadText = "用户名称"; cl.IsCondition = true; cl.IsCheck = true; cl.Length = 100; cl.IsNull = false; cl.IsUnique = true; cl.ErrMessage = "用户名称:必填且长度不能超过100或重复"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "bstopflag"; cl.HeadText = "是否激活"; cl.Visible = false; cl.IsCondition = true; cl.DictTypeID = "A04"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "enabled"; cl.HeadText = "激活状态"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "sphone"; cl.HeadText = "联系电话/手机"; cl.IsCondition = true; cl.IsCheck = true; cl.Length = 50; cl.ErrMessage = "联系电话/手机:长度不能超过50"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "slinkman"; cl.HeadText = "联系人"; cl.IsCondition = true; cl.IsCheck = true; cl.Length = 50; cl.ErrMessage = "联系人:长度不能超过50"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "saddress"; cl.HeadText = "地址"; cl.IsCondition = true; cl.IsCheck = true; cl.Length = 200; cl.ErrMessage = "地址:长度不能超过200"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "semail"; cl.HeadText = "电子信箱"; cl.IsCondition = true; cl.IsCheck = true; cl.Length = 50; cl.ErrMessage = "电子信箱:格式不正确且长度不能超过50"; cl.DataType = Tag.Email; pg.AddColumn(cl);
            return pg;
        }
    }
}